package org.gap.service;

import java.util.List;
import java.util.Set;

import org.gap.domain.TiersRib;
import org.gap.domain.Utilisateurs;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/GAP_v2-security-context.xml",
		"file:./resources/GAP_v2-service-context.xml",
		"file:./resources/GAP_v2-dao-context.xml",
		"file:./resources/GAP_v2-web-context.xml" })
@Transactional
public class TiersRibServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected TiersRibService service;

	/**
	 * Instantiates a new TiersRibServiceTest.
	 *
	 */
	public TiersRibServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Save an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void saveTiersRibUtilisateursByTrbUserModification() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersRibUtilisateursByTrbUserModification 
		Integer trbTiers = 0;
		Integer trbRib = 0;
		Utilisateurs related_utilisateursbytrbusermodification = new org.gap.domain.Utilisateurs();
		TiersRib response = null;
		response = service.saveTiersRibUtilisateursByTrbUserModification(trbTiers, trbRib, related_utilisateursbytrbusermodification);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTiersRibUtilisateursByTrbUserModification
	}

	/**
	 * Operation Unit Test
	 * Return all TiersRib entity
	 * 
	 */
	@Test
	public void findAllTiersRibs() {
		// TODO: JUnit - Populate test inputs for operation: findAllTiersRibs 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<TiersRib> response = null;
		response = service.findAllTiersRibs(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllTiersRibs
	}

	/**
	 * Operation Unit Test
	 * Save an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void saveTiersRibUtilisateursByTrbUserCreation() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersRibUtilisateursByTrbUserCreation 
		Integer trbTiers_1 = 0;
		Integer trbRib_1 = 0;
		Utilisateurs related_utilisateursbytrbusercreation = new org.gap.domain.Utilisateurs();
		TiersRib response = null;
		response = service.saveTiersRibUtilisateursByTrbUserCreation(trbTiers_1, trbRib_1, related_utilisateursbytrbusercreation);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTiersRibUtilisateursByTrbUserCreation
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void deleteTiersRibUtilisateursByTrbUserCreation() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersRibUtilisateursByTrbUserCreation 
		Integer tiersrib_trbTiers = 0;
		Integer tiersrib_trbRib = 0;
		String related_utilisateursbytrbusercreation_usrUser = null;
		TiersRib response = null;
		response = service.deleteTiersRibUtilisateursByTrbUserCreation(tiersrib_trbTiers, tiersrib_trbRib, related_utilisateursbytrbusercreation_usrUser);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTiersRibUtilisateursByTrbUserCreation
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void deleteTiersRibUtilisateursByTrbUserModification() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersRibUtilisateursByTrbUserModification 
		Integer tiersrib_trbTiers_1 = 0;
		Integer tiersrib_trbRib_1 = 0;
		String related_utilisateursbytrbusermodification_usrUser = null;
		TiersRib response = null;
		response = service.deleteTiersRibUtilisateursByTrbUserModification(tiersrib_trbTiers_1, tiersrib_trbRib_1, related_utilisateursbytrbusermodification_usrUser);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTiersRibUtilisateursByTrbUserModification
	}

	/**
	 * Operation Unit Test
	 * Delete an existing TiersRib entity
	 * 
	 */
	@Test
	public void deleteTiersRib() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersRib 
		TiersRib tiersrib = new org.gap.domain.TiersRib();
		service.deleteTiersRib(tiersrib);
	}

	/**
	 * Operation Unit Test
	 * Save an existing TiersRib entity
	 * 
	 */
	@Test
	public void saveTiersRib() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersRib 
		TiersRib tiersrib_1 = new org.gap.domain.TiersRib();
		service.saveTiersRib(tiersrib_1);
	}

	/**
	 * Operation Unit Test
	 * Load an existing TiersRib entity
	 * 
	 */
	@Test
	public void loadTiersRibs() {
		Set<TiersRib> response = null;
		response = service.loadTiersRibs();
		// TODO: JUnit - Add assertions to test outputs of operation: loadTiersRibs
	}

	/**
	 * Operation Unit Test
	 * Return a count of all TiersRib entity
	 * 
	 */
	@Test
	public void countTiersRibs() {
		Integer response = null;
		response = service.countTiersRibs();
		// TODO: JUnit - Add assertions to test outputs of operation: countTiersRibs
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findTiersRibByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findTiersRibByPrimaryKey 
		Integer trbTiers_2 = 0;
		Integer trbRib_2 = 0;
		TiersRib response = null;
		response = service.findTiersRibByPrimaryKey(trbTiers_2, trbRib_2);
		// TODO: JUnit - Add assertions to test outputs of operation: findTiersRibByPrimaryKey
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
